using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Input.Touch;
using Microsoft.Xna.Framework.Media;


namespace GameWP
{
    public class PlayBGComponent : Microsoft.Xna.Framework.DrawableGameComponent
    {
        Game _game;
        private SpriteBatch _spriteBatch;
        private Vector2 touchPosition, pretouchPosition;
        private Vector2 _parallax;
        public Vector2 Parallax
        {
            get { return _parallax; }
            set { _parallax = value; }
        }

        //Initilation
        public PlayBGComponent(Game game, SpriteBatch spriteBatch)
            : base(game)
        {
            _game = game;
            _spriteBatch = spriteBatch;
            Parallax = Vector2.One;

            //Init list menu item
        }

        public override void Initialize()
        {
            // TODO: Add your initialization code here
                base.Initialize();
        }

        public override void Update(GameTime gameTime)
        {
            float elapsedTime = (float)gameTime.ElapsedGameTime.TotalSeconds;
            // TODO: Add your update code here    
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                _game.Exit();
            //Key input
            TouchCollection touchCollection = TouchPanel.GetState();
            touchPosition = Vector2.Zero;
            if (touchCollection.Count > 0)
            {
                touchPosition = touchCollection[0].Position;
                pretouchPosition = touchPosition;
            }
            ManagerGame.AppearAura.Update(gameTime);
        }

        public override void Draw(GameTime gameTime)
        {
            _spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, ManagerGame.camera.GetViewMatrix(Vector2.One));
                ManagerGame.treasure.Draw(_spriteBatch, gameTime);
                ManagerGame.managerAHero.ManageDrawAHero(_spriteBatch, gameTime);
                ManagerGame.managerZombie.ManageDraw(_spriteBatch, gameTime);
                ManagerGame.luffy.Draw(_spriteBatch, gameTime);
                ManagerGame.managerTrap.ManageDrawTrapWasUsed(_spriteBatch, gameTime);
                ManagerGame.AppearAura.Draw(_spriteBatch, gameTime);
            base.Draw(gameTime);
            _spriteBatch.End();
        }
    }
}
